package cn.edu.zut.dao;

import cn.edu.zut.domin.BookIndex;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

//更改码云仓库中的文件注释信息，重新推了一次
public interface IBookIndexDao {
    /**
     * 查询所有索引
     * @return
     * @throws Exception
     */
    @Select("select * from bookIndex")
    public List<BookIndex> findAll() throws Exception;

    /**
     * 查询索引By typeId
     * @return
     * @throws Exception
     */
    @Select("select * from  bookIndex where typeId = #{typeId}")
    public List<BookIndex> findBookByTypeId(String typeId) throws Exception;

    /**
     * 保存索引
     * @param bookIndex
     * @throws Exception
     */
    @Insert("insert into bookIndex(typeId,typeName) values(#{typeId},#{typeName})")
    public void saveBookIndex(BookIndex bookIndex) throws Exception;

    /**
     * 删除索引by typeId
     * @param typeId
     * @throws Exception
     */
    @Delete("delete from bookIndex where typeId=#{typeId}")
    public void deleteBookIndex(String typeId) throws Exception;

    /**
     * 更新索引byid
     * @param bookIndex
     * @throws Exception
     */
    @Update("update bookIndex set typeName=#{typeName} where typeId=#{typeId}")
    public void updateBookIndex(BookIndex bookIndex) throws Exception;

}
